/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.MessageManager;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.util.Map;
/*    */ import javax.servlet.RequestDispatcher;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ 
/*    */ public class ShowUpdateWhiteBoard extends AbstractAction
/*    */ {
/* 20 */   private int id = 0;
/*    */ 
/*    */   public ShowUpdateWhiteBoard(AbstractHttpServlet servlet) {
/* 23 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public ShowUpdateWhiteBoard(AbstractHttpServlet servlet, String id) {
/* 27 */     super(servlet);
/* 28 */     this.id = Util.str2Int(id);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 34 */     MessageManager manager = new MessageManager();
/*    */ 
/* 36 */     User u = super.getLoginUser(request);
/*    */ 
/* 38 */     Map item = manager.getDetail(this.id);
/* 39 */     if (item == null) {
/* 40 */       request.getRequestDispatcher("/errorpage.jsp").forward(request, 
/* 41 */         response);
/* 42 */       return;
/*    */     }
/* 44 */     String createUserId = (String)item.get("CreateUserId");
/* 45 */     Integer messageType = (Integer)item.get("MessageType");
/* 46 */     boolean flag = checkRight(u, createUserId, messageType);
/* 47 */     if (!flag) {
/* 48 */       request.getRequestDispatcher("/errorpage.jsp").forward(request, 
/* 49 */         response);
/* 50 */       return;
/*    */     }
/* 52 */     request.setAttribute("item", item);
/* 53 */     request.getRequestDispatcher("/whiteboard_modify.jsp").forward(request, 
/* 54 */       response);
/*    */   }
/*    */ 
/*    */   private boolean checkRight(User u, String createUserId, Integer messageType) {
/* 58 */     if (messageType.intValue() == 1) {
/* 59 */       return false;
/*    */     }
/*    */ 
/* 62 */     if (u.isAdmin) {
/* 63 */       return true;
/*    */     }
/*    */ 
/* 67 */     return u.userId.equals(createUserId);
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ShowUpdateWhiteBoard
 * JD-Core Version:    0.6.1
 */